<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>用户登录</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Arial', sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .login-container {
            background: rgba(255, 255, 255, 0.9);
            padding: 40px;
            border-radius: 10px;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 400px;
        }

        .login-header {
            text-align: center;
            margin-bottom: 30px;
        }

        .login-header h2 {
            color: #333;
            font-size: 28px;
            font-weight: 600;
        }

        .login-form .form-group {
            margin-bottom: 20px;
        }

        .login-form label {
            display: block;
            margin-bottom: 8px;
            color: #555;
            font-weight: 500;
        }

        .login-form input {
            width: 100%;
            padding: 12px 15px;
            border: 2px solid #ddd;
            border-radius: 5px;
            font-size: 16px;
            transition: border-color 0.3s;
        }

        .login-form input:focus {
            outline: none;
            border-color: #667eea;
        }

        .login-form button {
            width: 100%;
            padding: 12px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 5px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: transform 0.2s;
        }

        .login-form button:hover {
            transform: translateY(-2px);
        }

        .login-form button:active {
            transform: translateY(0);
        }

        .form-footer {
            text-align: center;
            margin-top: 20px;
        }

        .form-footer a {
            color: #667eea;
            text-decoration: none;
            font-size: 14px;
        }

        .form-footer a:hover {
            text-decoration: underline;
        }

        .error-message {
            color: #e74c3c;
            font-size: 14px;
            margin-top: 5px;
            display: none;
        }

        .success-message {
            color: #27ae60;
            font-size: 14px;
            margin-top: 15px;
            text-align: center;
            display: none;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <div class="login-header">
            <h2>用户登录</h2>
        </div>

        <form action="/day30_tomcat_serlet_war/login" method="post" id="loginForm"  class="login-form">
            <div class="form-group">
                <label for="username">用户名</label>
                <input type="text" id="username" name="username" placeholder="请输入用户名" required>
                <div class="error-message" id="usernameError">请输入用户名</div>
            </div>

            <div class="form-group">
                <label for="password">密码</label>
                <input type="password" id="password" name="password" placeholder="请输入密码" required>
                <div class="error-message" id="passwordError">请输入密码</div>
            </div>

            <button type="submit">登录</button>

            <div class="success-message" id="successMessage">
                登录成功！欢迎回来！
            </div>
        </form>

        <div class="form-footer">
            <a href="#">忘记密码？</a> |
            <a href="register.html">立即注册</a>
        </div>
    </div>

<!--    <script>-->
<!--        document.getElementById('loginForm').addEventListener('submit', function(e) {-->
<!--            e.preventDefault();-->
<!--            console.log(e)-->

<!--            // 获取输入值-->
<!--            const username = document.getElementById('username').value.trim();-->
<!--            const password = document.getElementById('password').value.trim();-->

<!--            // 隐藏之前的消息-->
<!--            document.getElementById('usernameError').style.display = 'none';-->
<!--            document.getElementById('passwordError').style.display = 'none';-->
<!--            document.getElementById('successMessage').style.display = 'none';-->

<!--            // 验证输入-->
<!--            let isValid = true;-->

<!--            if (username === '') {-->
<!--                document.getElementById('usernameError').style.display = 'block';-->
<!--                isValid = false;-->
<!--            }-->

<!--            if (password === '') {-->
<!--                document.getElementById('passwordError').style.display = 'block';-->
<!--                isValid = false;-->
<!--            }-->



<!--        });-->

<!--        // // 实时验证-->
<!--        // document.getElementById('username').addEventListener('input', function() {-->
<!--        //     if (this.value.trim() !== '') {-->
<!--        //         document.getElementById('usernameError').style.display = 'none';-->
<!--        //     }-->
<!--        // });-->
<!--        //-->
<!--        // document.getElementById('password').addEventListener('input', function() {-->
<!--        //     if (this.value.trim() !== '') {-->
<!--        //         document.getElementById('passwordError').style.display = 'none';-->
<!--        //     }-->
<!--        // });-->
<!--    </script>-->
</body>
</html>